<?php

namespace App\Models;

use App\Models\traits\Search;
use App\Models\traits\SerializeDate;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Log extends Model
{
    use HasFactory,SerializeDate,Search;
    protected  $fillable=['user_id','type','content'];
    public $appends=['username',"usermobile",'departmentname'];
    public function user(){
        return $this->belongsTo(User::class);
    }
    public function getUsernameAttribute(){
        return $this->user()->value('name');
    }
    public function getUsermobileAttribute(){
        return $this->user()->value('mobile');
    }
    public function getDepartmentnameAttribute(){
        return $this->user->department()->value("name");
    }
}
